//
//  TTBasicMisc.m
//  Tint
//
//  Created by Kevin Wu on 2/23/12.
//  Copyright (c) 2012 Telligenty. All rights reserved.
//

#import "TTBasicMisc.h"


#pragma mark - Constants

NSString *const TTTintVersion = @"2.0";
NSString *const TTTintErrorDomain = @"com.tint";
NSString *const TTTintBundleName = @"Tint.bundle";



#pragma mark - Bundle

NSBundle *TTTintBundle(void) {
    static NSBundle *bundle = nil;
    if (bundle == nil) bundle = [[NSBundle alloc] initWithPath:TTTintBundlePath()];
    return bundle;
}

NSString *TTTintBundlePath(void) {
    static NSString *bundlePath = nil;
    if (bundlePath == nil) bundlePath = [[[NSBundle mainBundle] pathForResource:TTTintBundleName ofType:nil] copy];
    return bundlePath;
}

NSString *TTTintBundleResourcePath(NSString *relativePath) {
    return [TTTintBundlePath() stringByAppendingPathComponent:relativePath];
}

NSString *TTTintBundleResourcePathForName(NSString *name) {
    return [TTTintBundle() pathForResource:name ofType:nil];
}

UIImage *TTTintBundleImage(NSString *relativePath) {
    return [UIImage imageWithContentsOfFile:TTTintBundleResourcePath(relativePath)];
}


UIImage *TTCachedImage(NSString *name) {
    return [UIImage imageNamed:name];
}

UIImage *TTUncachedImage(NSString *name) {
    NSString *path = [[NSBundle mainBundle] pathForResource:name ofType:nil];
    return [UIImage imageWithContentsOfFile:path];
}



#pragma mark - Localization

NSString *TTLocalizedString(NSString *key, NSString *comment) {
    return [TTTintBundle() localizedStringForKey:key value:key table:nil];
}

